/**
 * Project hdmap
 * @author shengjialiang
 * @version v1.0
 */

#include "map_common/GlobeSetting.h"

/**
 * CGlobeSetting implementation
 */

namespace Common
{    
    std::map<std::string, std::string> CGlobeSetting::ConfigStr = std::map<std::string, std::string>();
    std::map<std::string, double> CGlobeSetting::ConfigNum = std::map<std::string, double>();
    std::map<std::string, void*> CGlobeSetting::ConfigPtr = std::map<std::string, void*>();
    static OpenThreads::Mutex mPtrMutex;
    CGlobeSetting::CGlobeSetting()
    {

    }

    CGlobeSetting::~CGlobeSetting()
    {


    }

    bool CGlobeSetting::pushPtr(const std::string& in_key, void* pRefData)
    {
        bool r = false;
        mPtrMutex.lock();
        {
            std::map<std::string, void*>::iterator itr = ConfigPtr.find(in_key);
            if (itr == ConfigPtr.end())
            {
                ConfigPtr[in_key] = pRefData;
                r = true;
            }
        }
        mPtrMutex.unlock();
        return r;
    }

    void* CGlobeSetting::getPtr(const std::string& in_key)
    {
        void* pData = NULL;
        mPtrMutex.lock();
        {
            std::map<std::string, void*>::iterator itr = ConfigPtr.find(in_key);
            if (itr != ConfigPtr.end())
            {
                pData = itr->second;
            }
        }
        mPtrMutex.unlock();
        return pData;
    }
}